package com.bci.pwtz.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.bci.pwtz.exception.PwtzDatabaseException;
import com.bci.pwtz.mysql.dao.DeviceTypeMapper;
import com.bci.pwtz.mysql.model.DeviceType;
import com.bci.pwtz.service.DeviceTypeService;

/**
 * 一句话描述 <br/>
 * <p>
 * Description:<br/>
 * <p>
 * TODO 详细描述
 * 
 * <p>
 * For Examples <br/>
 * 
 * <PRE>
 *      TODO 代码使用示例
 * </PRE>
 * <p>
 */
@Service
public class DeviceTypeServiceImpl implements DeviceTypeService
{

    private DeviceTypeMapper deviceTypeMapper;
    
    /**
     * @return the deviceTypeMapper
     */
    public DeviceTypeMapper getDeviceTypeMapper()
    {
        return deviceTypeMapper;
    }

    /**
     * @param deviceTypeMapper the deviceTypeMapper to set
     */
    public void setDeviceTypeMapper(DeviceTypeMapper deviceTypeMapper)
    {
        this.deviceTypeMapper = deviceTypeMapper;
    }

    private static final Logger _logger = Logger.getLogger(DeviceTypeServiceImpl.class);
    
    public List<DeviceType> selectAll(int voltagelevel) throws PwtzDatabaseException
    {
        List<DeviceType> list = new ArrayList<DeviceType>();
        
        if (_logger.isInfoEnabled())
        {
        }
        try
        {
                list = deviceTypeMapper.selectAll(voltagelevel);
        }
        catch (DataAccessException e)
        {
            _logger.error(ExceptionUtils.getStackTrace(e));
            throw new PwtzDatabaseException();
        }
        if (list!=null)
        {
            _logger.debug("selectAll:result DeviceTypeList=" + list.size());
        }
        
        return list;
    }
}
